<template>
  <div class="container">
    <nav-bar :title="titleName" />
    <div class="form">
      <div class="title">{{titleName}}</div>
      <!-- 密码 -->
      <div class="ipt ipt-email">
        <input 
          type="text" 
          placeholder="验证码" 
          v-model="validata" 
          @input="codeInput"
        />
      </div>
      <div class="form-btns">
        <div class="form-btn" @click="registerNext">下一步</div>
      </div>
    </div>
  </div>
</template>

<script>
import NavBar from 'components/common/NavBar'
import { validateInputSingle } from '../../utils/'
export default {
  components: {
    NavBar
  },
  data() {
    return {
      validata: '',
      isForget: false,
    }
  },
  computed: {
    titleName(){
      let nameObj = {
        normal: '注册',
        bind: '绑定',
        forget: '找回密码',
      }
      return nameObj[this.$route.query.type]
    }
  },
  mounted() {
    this.isForget = this.$route.query.type === 'forget'
  },
  methods: {
    registerNext(){
      if(this.$route.query.from === 'user'){
        this.$router.push({
          path: '/userBase'
        })
      } else {
        this.$route.query.validata = this.validata
        this.$router.push({
          path: '/registerPassword',
          query: this.$route.query
        })
      }
    },
    codeInput(e){
      let val = e.target.value
      this.validata = validateInputSingle(val)
    }
  },

}
</script>

<style scoped>
.container{
  background: #ffffff;
}
.form{
  padding: 40px 30px;
}
.form .title{
  font-size: 22px;
  line-height: 1.6;
  padding-bottom: 20px;
}
.form .ipt{
  display: flex;
  align-items: center;
  margin-bottom: 30px;
}
.form .ipt input{
  flex-grow: 1;
  height: 30px;
  line-height: 30px;
  font-size: 16px;
  border-bottom: 1px solid #e0e0e0;
}
.form .ipt .country-num{
  height: 30px;
  line-height: 30px;
  padding-right: 10px;
  border-bottom: 1px solid #e0e0e0;
}
.form-btn{
  font-size: 14px;
  text-align: center;
  line-height: 45px;
  color: #ffffff;
  /* background-color: #d1d1d1; */
  background-color: #000;
}
.tips{
  display: block;
  font-size: 12px;
  line-height: 3.5;
  color: #666666;
  text-align: left;
  margin-bottom: 60px;
}
</style>